package koala.kuangjiademo.net;

import android.content.Context;

import koala.kuangjiademo.data.ResponsePacket;


public abstract class OnResponsePacketListener<DATA> extends OnResponseListener<ResponsePacket<DATA>> {
    public OnResponsePacketListener(Context context) {
        super(context);
    }

    public OnResponsePacketListener(Context context, boolean successOnly, boolean autoDismissProgress) {
        super(context, successOnly, autoDismissProgress);
    }

    @Override
    public void onResponse(IResponseStatus status, ResponsePacket<DATA> response) {
        onResponsePacket(status, status.isSuccess() ? response.data : null);
    }

    /**
     * @param response Nullable when failed
     */
    public abstract void onResponsePacket(IResponseStatus status, DATA response);
}
